// 模型对数据库的表做映射
import { AutoIncrement, Column, CreatedAt, Default, DeletedAt, Model, PrimaryKey, Table, UpdatedAt } from "sequelize-typescript";

@Table({
    timestamps: true, // 自动维护时间
    tableName: "users", // 数据库表名称
    freezeTableName: true,  // 禁止修改表名，如果不写会把表名自动复数化，users
    paranoid: true, // 软删除
})
export default class User extends Model {
    @AutoIncrement // 自增
    @PrimaryKey // 主键
    @Column
    id!: number;
    
    @Column({
        defaultValue: "",
        comment: "账户名"
    })
    account!: string

    @Column({
        defaultValue: "",
        comment: "密码"
    })
    pwd!: string

    @Column({
        defaultValue: "",
        comment: "token"
    })
    token!: string

    @Default(new Date())
    @CreatedAt
    @Column
    created_at!: Date;

    @Default(new Date())
    @UpdatedAt
    @Column
    updated_at!: Date;

    @DeletedAt
    deleted_at?: Date;
}
